package utils;

public class StringUtil {
	
//	private static Log logger = LogFactory.getLog(StringUtil.class);

	public static boolean isEmpty(String str){
		if(str == null || str.equals("") || str.equals("null")){
			return true;
		}
		return false;
	}

	public static boolean isEmpty(String... strs){
		if(strs.length == 0){
			return true;
		}
		for(String str : strs){
			if(isEmpty(str)){
				return true;
			}
		}
		return false;
	}

	public static String replaceLast(String text, String regex, String replacement) {
		return text.replaceFirst("(?s)"+regex+"(?!.*?"+regex+")", replacement);
	}
	
	/**
	 * 测试
	 */
	public static void main(String[] args) {
//		String testStr1 = null;
//		System.out.println("1:" + isEmpty(testStr1));
//		String testStr2 = "";
//		System.out.println("2:" + isEmpty(testStr2));
//		String testStr3 = "null";
//		System.out.println("3:" + isEmpty(testStr3));
//		Object testObj1 = null;
//		System.out.println("4:" + isEmpty((String)testObj1));
//		System.out.println("5:" + isEmpty(String.valueOf(testObj1)));
////		System.out.println("6:" + isEmpty(testObj1.toString())); //报错
//
//		System.out.println("7:" + isEmpty(testStr1, testStr2, testStr3));
//		System.out.println("8:" + isEmpty("a", testStr1));
//		System.out.println("9:" + isEmpty("s"));

		System.out.println(replaceLast("foo AB bar AB done", "AB", "--"));
	}
	
	

}
